<%@ page language="java" contentType="text/html; charset=utf-8"pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>新增技师</title>
		<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet" type="text/css">
		<link href="<c:url value="/resources/css/default/easyui.css" />" rel="stylesheet" type="text/css">
		<link href="<c:url value="/resources/css/icon.css" />" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.7.2.js" />"></script>
		<script type="text/javascript" src="<c:url value="/resources/js/jquery.easyui.min.js" />"></script>
		<script type="text/javascript" src="<c:url value="/resources/js/easyui-lang-zh_CN.js" />"></script>
		<script type="text/javascript">
			function clearForm(){
				$("#worker_no").val('');
				$("#worker_name").val('');
				$("#workerTypeName").val('');
				$("#worker_type_id").val('');
				$("#birthDate").val('');
				$("input[name='gender'][value=${gender_man}]").attr("checked",true); 
				$("#id_card_no").val('');
				$("#remark").val('');
				<c:forEach var="code" items="${workerStatusList}" varStatus="status">				
					<c:if test="${status.index == 0}">
						$("input[name='status'][value=${code.code}]").attr("checked",true);
					</c:if>				
				</c:forEach>
			}
					
			function submitForm(){
				var flag = "false";
				$.ajax({
					url:'checkWorkerNo.do',
					data:{'workerNo':$.trim($("#worker_no").val())},
					type:'post',
					dataType:'json',
					async:false,
					cache:false,
					success:function(data){
						flag = data.toString();
					}
				});
				
				if(flag == 'true'){
					$.messager.alert('操作结果','技师编号已存在','warning');
					return false;
				}
				
				$("#addWorkerForm").submit();		
			}
			
			function onResetWorkerType(){
				$("#queryWorkerTypeName").val('');
				$("#printerNo").val('');
			}
			
			function onQueryWorkerType(){				
				$('#workerTypeTable').datagrid({
					url: '../workerType/queryWorkerType.do',
					pageNumber:1,				
					queryParams:{workerTypeName:$("#queryWorkerTypeName").val(),						
						printerNo:$.trim($('#printerNo').val())}
				});
			}
			
			function onSelWorkerType(){
				$('#selectWorkerType').window('open');
			}
			
			$(function(){
				if('${result}' != null && '${result}' != ''){
					$.messager.alert('操作结果','${result}');
				}
			});
		</script>
	</head>
	
	<body>
		<div class="easyui-panel" title="新增技师" fit="true">
			<div style="padding:10px 0 10px 60px; text-align: right;">
				<form name="addWorkerForm" id="addWorkerForm" method="post" action="addWorker">
					<table  style="text-align: center; border:1px;width:400px;">
						<tr>
							<td align="right" style="height:28px;">技师编号：</td>
	    					<td align="left">
	    						<input class="easyui-validatebox" style="width:150px;" type="text" 
	    							name="worker_no" id="worker_no" required="true" />
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">技师名称 ：</td>
	    					<td align="left">
	    						<input class="easyui-validatebox" style="width:150px;" type="text" name="worker_name" id="worker_name" data-options="required:true" />
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">技师类型 ：</td>
	    					<td align="left">
	    						<input class="easyui-validatebox" style="width:150px;" type="text" name="workerTypeName" id="workerTypeName" data-options="required:true" />
	    						<input type="hidden" name="worker_type_id" id="worker_type_id" />
	    						&nbsp;&nbsp;
	    						<a href="javascript:void(0)" class="easyui-linkbutton" onclick="onSelWorkerType()">选择</a>
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">生日：</td>
	    					<td align="left">
	    						<input class="easyui-datebox" style="width:155px;" id="birthDate"  />
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">性别：</td>
	    					<td align="left">
	    						<input type="radio" name="gender" id="gender" value="${gender_man}" checked="checked" />男
	    						&nbsp;&nbsp;&nbsp;&nbsp;
	    						&nbsp;&nbsp;&nbsp;
	    						<input type="radio" name="gender" id="gender" value="${gender_women}" />女
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">IC卡号：</td>
	    					<td align="left">
	    						<input class="easyui-validatebox" style="width:150px;" type="text" name="id_card_no" id="id_card_no" />
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">状态：</td>
	    					<td align="left">
	    						<c:forEach var="code" items="${workerStatusList}" varStatus="status">
	    							<input type="radio" name="status" id="status" value="${code.code}" 
	    								<c:if test="${status.index == 0}">checked="checked"</c:if>/>${code.name}
	    							&nbsp;&nbsp;&nbsp;&nbsp;
	    						</c:forEach>
	    					</td>
						</tr>
						
						<tr>
							<td align="right" style="height:28px;">备注：</td>
	    					<td align="left">
	    						<textarea class="easyui-validatebox" style="width:250px;height: 100px;" name="remark" id="remark" ></textarea>
	    					</td>
						</tr>
					</table>
				</form>
			</div>
			
			<div style="margin-left:170px;padding:5px">
	    		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">保存</a>
	    		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">重置</a>
	    	</div>
		</div>
		
		<div id="selectWorkerType" class="easyui-window" title="技师类型选择" data-options="modal:true,closed:true,iconCls:'icon-save'" style="width:700px;height:400px;">
			<table id="workerTypeTable" class="easyui-datagrid" title="技师类型列表" style="width:700px;height:250px;"
	 			data-options="rownumbers:true,singleSelect:true,toolbar:'#tb', border:false,singleSelect:true,
	 					fit:true,fitColumns:true,pagination:true,url:'../workerType/queryWorkerType.do',onClickRow:function(rowIndex, rowData){
		 						$('#worker_type_id').val(rowData.id);
		 						$('#workerTypeName').val(rowData.worker_type_name);
		 						$('#selectWorkerType').window('close');
		 				}">
				<thead>
					<tr>
						<th data-options="field:'worker_type_name',width:80,align:'center'">技师类型</th>
						<th data-options="field:'seq',width:120,align:'center'">显示顺序</th>
						<th data-options="field:'printer_no',width:120,align:'center'">派工打印机</th>
					</tr>
				</thead>
			</table>
			
			<div id="tb" style="padding:5px;height:auto">
				<form id="queryWorkerTypeForm" name="queryWorkerTypeForm" action="queryWorkerType" method="post">
				<div>
					技师类型名称: <input class="easyui-validatebox" name="queryWorkerTypeName" id="queryWorkerTypeName" style="width:100px">
					&nbsp;&nbsp;&nbsp;&nbsp;
					派工打印机: <input class="easyui-numberbox"  type="text" name="printerNo" id="printerNo"  style="width:100px"/>
					&nbsp;&nbsp;
					<a href="#" class="easyui-linkbutton" id="searchBtn" style="text-align: center" onclick="onQueryWorkerType()">查询</a>
					<a href="#" class="easyui-linkbutton" id="resetBtn" style="text-align: center" onclick="onResetWorkerType()">清空</a>
				</div>
				</form>
			</div>
		</div>
	</body>
</html>